package asia.myjhotel.xiaozhiagent.config;


import asia.myjhotel.xiaozhiagent.store.MongoChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SeprateMemoryChatConfig {

    @Resource
    private MongoChatMemoryStore mongoChatMemoryStore;


    @Bean
    ChatMemoryProvider chatMemoryProvider() {
        return memoryId -> MessageWindowChatMemory.builder()
                .id(memoryId)
                //添加回话持久化存储操作的对象
                .chatMemoryStore(mongoChatMemoryStore)
                .maxMessages(10)
                .build();
    }
}
